package com.qf.spring2202.customfactory.service.impl;

import com.qf.spring2202.customfactory.dao.UserDao;
import com.qf.spring2202.customfactory.dao.impl.UserDaoImpl;
import com.qf.spring2202.customfactory.entity.User;
import com.qf.spring2202.customfactory.service.UserService;

public class UserServiceImpl implements UserService {


    private UserDao userDao;

    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    @Override
    public User getUser(Integer id) {
        System.out.println("UserServiceImpl 的 getUser 执行了 .....");
        final User user = userDao.getUserById(id);
        return user;
    }

    /**
     * 没有IOC框架之前手写代码创建对象的方式
     * @param args
     */
    public static void main(String[] args) {

        // 1. 创建对象
        final UserServiceImpl userService = new UserServiceImpl();

        final UserDaoImpl userDao = new UserDaoImpl();

        // 2. 手写代码处理对象之间的依赖关系
        userService.setUserDao(userDao);



    }
}
